package com.bigflexlib.x.flash.events
{
	import com.bigflexlib.x.mx.core.Application.App;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	[Event(name="enterFrame", type="flash.events.Event")]	
	
	public class EnterFrameHelper extends EventDispatcher
	{
	
		public function EnterFrameHelper( )
		{
			try {
				App.app.addEventListener( Event.ENTER_FRAME, h );
			} catch ( e:Error ){
				var t:Timer = new Timer( 100 );
				t.addEventListener( TimerEvent.TIMER, h );
				t.start();
			}
		}
		
		private function h( event:Event ):void
		{
			dispatchEvent( new Event( Event.ENTER_FRAME ) );
		}
		
		
		private static var _i:EnterFrameHelper;
		public static function get i():EnterFrameHelper
		{
			if ( _i == null )
				_i = new EnterFrameHelper();
			return _i;
		}
	}
}